package com.ljh.controller;

import com.github.pagehelper.PageInfo;
import com.ljh.pojo.Article;
import com.ljh.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LJH
 * @date 2020/7/26 21:28
 */

@Controller
@RequestMapping("blog")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("articlePage")
    public String testPageHelper(@RequestParam(value = "pageNum",defaultValue = "1")int pageNum,
                                            Model model){
        PageInfo<Article> userByPage = articleService.findUserByPage(pageNum, 5);
        model.addAttribute("pageInfo",userByPage);
        model.addAttribute("articleList",userByPage.getList());
        return "/client/index";
    }
}
